//
// Created by hamlet on 2022/1/14.
//

#ifndef SNAKE_GAME_PLAYER_H
#define SNAKE_GAME_PLAYER_H

#include <QString>
#include <QColor>
#include "message.h"

class PlayerInfo : public Message {
public:
    PlayerInfo(QString name, QString intro, const QColor &color = {}, qint64 id = 0LL);
    ~PlayerInfo() override = default;
    static PlayerInfo *parseJson(const QJsonObject &json);
    [[nodiscard]] QJsonObject toJson() const override;

    [[nodiscard]] QString simpleInfo() const;

private:
    qint64 m_ID;  // TODO 所有ID改为可定义类型
    QString m_name;
    QString m_intro;
    QColor m_snakeColor;

public:
    [[nodiscard]] qint64 getID() const { return m_ID; }
    void generateRandomID();
    [[nodiscard]] const QString &getName() const { return m_name; }
    [[nodiscard]] const QString &getIntro() const { return m_intro; }
    [[nodiscard]] const QColor &getSnakeColor() const { return m_snakeColor; }
    void setSnakeColorRGB(int r, int g, int b);
};


#endif //SNAKE_GAME_PLAYER_H
